package com.maple.visit;

import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 搜集表民
 *
 * @author maple
 * @version 1.0
 * @since 2020-11-27 00:25
 */
@Getter
public class TableNameVisitor extends MySqlASTVisitorAdapter {
    private final List<String> tableNameList = new ArrayList<>();

    @Override
    public boolean visit(SQLExprTableSource x) {
        tableNameList.add(x.getName().getSimpleName());
        return super.visit(x);
    }
}
